function parent = tournament_selection(population,pool_size,tour_size)
    [variables,pop] = size(population);
    rank = variables - 1;
    distance = variables;
 
    for i=1:pool_size
        candidate=[];
        for j=1:tour_size
            candidate(j)=floor(pop*rand())+1;
            
            if j>1
                 while ~isempty(find(candidate(1:j-1)==candidate(j)))
                     candidate(j)=floor(pop*rand())+1;
                 end
            end
            
           
        end
        for k=1:tour_size
            c_obj_rank(k)=population(rank,candidate(k));
            c_obj_distance(k)=population(distance,candidate(k));
        end
        
        min_candidate=find(c_obj_rank==min(c_obj_rank));
        
        if length(min_candidate)~=1
            max_distance_candidate=find(c_obj_distance(min_candidate)==max(c_obj_distance(min_candidate)));
            parent(:,i)=population(:,candidate(min_candidate(max_distance_candidate(1))));
        else
            parent(:,i)=population(:,candidate(min_candidate(1)));
        end
        
        
    end
end

